//
//  QKStatusCellBottomView.m
//  QKWeibo-OC
//
//  Created by iMac_Kurt on 16/9/1.
//  Copyright © 2016年 Kurt_Qi. All rights reserved.
//

#import "QKStatusCellBottomView.h"
#import "UIButton+QKButton.h"
#import <Masonry.h>

@interface QKStatusCellBottomView ()
/// 转发按钮
@property (nonatomic, strong) UIButton *retweetedButton;
/// 评论按钮
@property (nonatomic, strong) UIButton *commentButton;
/// 点赞按钮
@property (nonatomic, strong) UIButton *likeButton;
/// 竖线
@property (nonatomic, strong) UIView *firstSeparateLine;
@property (nonatomic, strong) UIView *secondSeparateLine;
@end

@implementation QKStatusCellBottomView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        // 设置界面
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    self.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
    
    // 添加子控件
    [self addSubview:self.retweetedButton];
    [self addSubview:self.commentButton];
    [self addSubview:self.likeButton];
    
    [self addSubview:self.firstSeparateLine];
    [self addSubview:self.secondSeparateLine];
    
    // 自动布局
    [self.retweetedButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.left.equalTo(self.mas_left).offset(QKStatusCellMargin);
        
    }];
    [self.commentButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.left.equalTo(self.retweetedButton.mas_right).offset(QKStatusCellMargin);
        make.width.equalTo(self.retweetedButton.mas_width);
    }];
    [self.likeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.left.equalTo(self.commentButton.mas_right).offset(QKStatusCellMargin);
        make.width.equalTo(self.commentButton.mas_width);
        make.right.equalTo(self.mas_right);
    }];
    
    // 分隔竖线
    static CGFloat separateLineWidth = 0.5;
    static CGFloat scale = 0.4;
    [self.firstSeparateLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.left.equalTo(self.retweetedButton.mas_right);
        make.width.equalTo(@(separateLineWidth));
        make.height.equalTo(self.mas_height).multipliedBy(scale);
    }];
    [self.secondSeparateLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.left.equalTo(self.commentButton.mas_right);
        make.width.equalTo(@(separateLineWidth));
        make.height.equalTo(self.mas_height).multipliedBy(scale);
    }];
}

#pragma mark - 懒加载控件
- (UIButton *)retweetedButton {
    if (_retweetedButton == nil) {
        _retweetedButton = [UIButton buttonWithTitle:@" 转发" color:[UIColor darkGrayColor] fontSize:12 imageName:@"timeline_icon_retweet"];
    }
    return _retweetedButton;
}

- (UIButton *)commentButton {
    if (_commentButton == nil) {
        _commentButton = [UIButton buttonWithTitle:@" 评论" color:[UIColor darkGrayColor] fontSize:12 imageName:@"timeline_icon_comment"];
    }
    return _commentButton;
}

- (UIButton *)likeButton {
    if (_likeButton == nil) {
        _likeButton = [UIButton buttonWithTitle:@" 赞" color:[UIColor darkGrayColor] fontSize:12 imageName:@"timeline_icon_like"];
    }
    return _likeButton;
}

- (UIView *)firstSeparateLine {
    if (_firstSeparateLine == nil) {
        UIView *v = [[UIView alloc] init];
        v.backgroundColor = [UIColor darkGrayColor];
        _firstSeparateLine = v;
    }
    return _firstSeparateLine;
}

- (UIView *)secondSeparateLine {
    if (_secondSeparateLine == nil) {
        UIView *v = [[UIView alloc] init];
        v.backgroundColor = [UIColor darkGrayColor];
        _secondSeparateLine = v;
    }
    return _secondSeparateLine;
}

@end
